#include "src/scene/nearestInfo.h"

#include <iostream>

NearestInfo::NearestInfo(Object *_obj, const double &_t, const Vector3D &_p, const Vector3D &_n)
        : object(_obj), t(_t), point(_p), normal(_n)
{
    if(object){
        Material material = _obj->getMaterial();
        if(material.useTexture())
            texture = material.texture->getColor(object, point);
        if(material.useBumpMapping())
            normal = material.bumpMapping->getNormal(object, point, normal);
    }
}

void NearestInfo::setAll(Object *_obj, const double &_t, const Vector3D &_p, const Vector3D &_n)
{
    object = _obj;
    t = _t;
    point = _p;
    normal = _n;
    if(object){
//        std::cout <<"Objeto " << object->getId() << std::endl;
        Material material = object->getMaterial();
        if(material.useTexture())
            texture = material.texture->getColor(object, point);
        if(material.useBumpMapping())
            normal = material.bumpMapping->getNormal(object, point, normal);
    }
}

NearestInfo& NearestInfo::operator=(const NearestInfo &_nearest)
{
    object = _nearest.object;
    t = _nearest.t;
    point = _nearest.point;
    normal = _nearest.normal;
    texture = _nearest.texture;

    return *this;
}
